<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>趣趣试玩</title>
    <!-- 存储服务 -->
    <script src="//cdn1.lncld.net/static/js/3.6.4/av-min.js"></script>
</head>


<style type="text/css">
    table
    {
        border-collapse: collapse;
        margin: 0 auto;
        text-align: center;
    }
    table td, table th
    {
        border: 1px solid #cad9ea;
        color: #666;
        height: 30px;
    }
    table thead th
    {
        background-color: #CCE8EB;
        width: 100px;
    }
    table tr:nth-child(odd)
    {
        background: #fff;
    }
    table tr:nth-child(even)
    {
        background: #F5FAFA;
    }
</style>
<script>
    var APP_ID = 'e7YcaJwupooGCtwXYK2KXgns-gzGzoHsz';
    var APP_KEY = '7rGUrltXBDxIpgQ6YgbtJpnT';
    var { Query, User } = AV;
    AV.init({
        appId: APP_ID,
        appKey: APP_KEY
    });
    var query = new AV.Query('drink1');
    query.select(['nickname', 'createdAt']);
    // 按时间，降序排列
    query.descending('createdAt');
    query.find().then(function (results) {
        // results 返回的就是有图片的 Todo 集合
        for(var i=0;i<results.length;i++){
            var obj = results[i];
            //添加一行
            var newTr = document.getElementById("myTable").insertRow();
            //添加三列
            var newTd0 = newTr.insertCell();
            var newTd1 = newTr.insertCell();
            //设置列内容和属性
            newTd0.innerHTML =obj.get('nickname')
            newTd1.innerHTML = obj.get('createdAt')

        }

        document.getElementById('t').innerText="当前人数 "+(i-2);


    }, function (error) {
        alert("请求失败，请联系管理员")
    });


</script>
<body>
<table width="95%" id="myTable" border="1">
    <caption >
        <h2 id="t">
            空空</h2>
    </caption>
</table>
</body>
</html>